#pragma once

#include "IPrimitive.h"
#include "String.h"
#include <map>

//
// d<bencoded string><bencoded element>e 
// The initial d and trailing e are the beginning and ending delimiters. 
// Note that the keys must be bencoded strings. The values may be any bencoded 
// type, including integers, strings, lists, and other dictionaries. Keys 
// must be strings and appear in sorted order (sorted as raw strings, not 
// alphanumerics). The strings should be compared using a binary comparison,
// not a culture-specific "natural" comparison.
//
//    Example: d3:cow3:moo4:spam4:eggse
//              { "cow" => "moo", "spam" => "eggs" } 
//    Example: d4:spaml1:a1:bee 
//              { "spam" => [ "a", "b" ] } 
//    Example: d9:publisher3:bob17:publisher-webpage15:www.example.com18:publisher.location4:homee
//              { "publisher" => "bob", "publisher-webpage" => "www.example.com", "publisher.location" => "home" }
//

namespace Torrent
{
    namespace Bencode
    {    
        class Dictionarie : public IPrimitive
        {
        public:
            Dictionarie(std::istream& stream);
            ~Dictionarie(void);

            virtual void print(std::ostream& stream, bool debug = false);
        private:
            typedef String* MapKey;
            typedef IPrimitive* MapElement;
            std::map<MapKey,MapElement> _map;
        };
    } //Bencode
}//Torrent